<template>
  <view class="mine-container" :style="{height: `${windowHeight}rpx`}">
    <!--顶部个人信息栏-->
    <view class="header-section">
      <view class="flex padding justify-between">
        <view class="flex align-center">
          <view v-if="!avatar" class="cu-avatar xl round bg-white">
            <view class="iconfont icon-people text-gray icon"></view>
          </view>
          <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
          </image>
          <view v-if="!name" @click="handleToLogin" class="login-tip">
            点击登录
          </view>
          <view v-if="name" @click="handleToEditInfo" class="user-info">
            <view class="u_title">
              用户名：{{ name }}
            </view>
						<view class="u_title">
						  姓名：{{ user.nickName }}
						</view>
          </view>
        </view>
        <view @click="handleToEditInfo" class="flex align-center">
          <text>个人信息</text>
          <view class="iconfont icon-right"></view>
        </view>
      </view>
    </view>

    <view class="content-section">
      <view class="mine-actions grid col-4 text-center">
        <view class="action-item" @click="handleToSetting">
          <view class="iconfont icon-setting text-pink icon"></view>
          <text class="text">账户设置</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont icon-service text-blue icon"></view>
          <text class="text">在线客服</text>
        </view>
        <view class="action-item" @click="handleGongDeXiang">
          <view class="iconfont icon-dianzan text-green icon"></view>
          <text class="text">点赞我们</text>
        </view>
        <view class="action-item" @click="handleLogout">
          <view class="iconfont icon-logout text-mauve icon"></view>
          <text class="text">退出登录</text>
        </view>
      </view>

<!--     <view class="menu-list">
				<h1>{{ title }}</h1>  
				<view class="team-members">  
					<ul>
					<li>
						<h3>毕设课题：</h3>
						<h4>{{subTitle}}</h4>  
					</li>
					<li v-for="member in teamMembers" :key="member.id">  
						{{ member.name }} - {{ member.role }}  
					</li>  
					</ul>  
					<p style="font-weight: 800;">{{ description }}</p>
				</view>  
      </view> -->

    </view>
  </view>
</template>

<script>
  import storage from '@/utils/storage'
  import { getUserProfile } from "@/api/system/user"
	
  export default {
    data() {
      return {
        name: this.$store.state.user.name,
				user:{},
        version: getApp().globalData.config.appInfo.version,
				title: '关于我们',  
				subTitle: '基于Springboot的产线温度预警系统设计与实现',  
				description: '版本号 v1.0.0',  
				teamMembers: [  
					{ id: 1, name: '傅振轩', role: '开发者' }
				],
				gongDe: 0
					}
    },
		onLoad() {
			this.getUser()
		},
    computed: {
      avatar() {
        return this.$store.state.user.avatar
      },
      windowHeight() {
        return uni.getSystemInfoSync().windowHeight - 50
      }
    },
    methods: {
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data
				})
			},
      handleToEditInfo() {
        this.$tab.navigateTo('/pages/mine/info/index')
      },
      handleToEditInfo() {
        this.$tab.navigateTo('/pages/mine/info/edit')
      },
      handleToSetting() {
        this.$tab.navigateTo('/pages/mine/setting/index')
      },
      handleToLogin() {
        this.$tab.reLaunch('/pages/login')
      },
      handleToAvatar() {
        this.$tab.navigateTo('/pages/mine/avatar/index')
      },
      handleLogout() {
        this.$modal.confirm('确定注销并退出系统吗？').then(() => {
          this.$store.dispatch('LogOut').then(() => {
						plus.runtime.restart();
            this.$tab.reLaunch('/pages/index')
          })
        })
      },
      handleHelp() {
        this.$tab.navigateTo('/pages/mine/help/index')
      },
      handleAbout() {
        this.$tab.navigateTo('/pages/mine/about/index')
      },
      handleJiaoLiuQun() {
        this.$modal.showToast('QQ群：①133713780、②146013835')
      },
      handleBuilding() {
        this.$modal.showToast('模块建设中~')
      },
      handleGongDeXiang() {
		this.gongDe ++
        this.$modal.showToast('功德：+'+this.gongDe)
      }
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #f5f6f7;
  }

	.about-us {  
	  text-align: center;  
	  padding: 20rpx;  
	}  
	  
	.team-members ul {  
	  list-style-type: none;  
	  padding: 0;  
	}  
	  
	.team-members li {  
	  margin: 10rpx 0;  
	}

	.bottom-img{
		width: 700rpx;
		height: 850rpx;
	}

	

  .mine-container {
    width: 100%;
    height: 100%;


    .header-section {
      padding: 15rpx 15rpx 45rpx 15rpx;
      background-color: #5958A6;
      color: white;

      .login-tip {
        font-size: 18rpx;
        margin-left: 10rpx;
      }

      .cu-avatar {
        border: 2rpx solid #eaeaea;

        .icon {
          font-size: 40rpx;
        }
      }

      .user-info {
        margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				align-items: left;
				gap: 20rpx;
				
        .u_title {
          font-size: 30rpx;
          line-height: 30rpx;
        }
      }
    }

    .content-section {
      position: relative;
      top: -50rpx;

      .mine-actions {
        margin: 15rpx 15rpx;
        padding: 45rpx 0rpx;
        border-radius: 8rpx;
        background-color: white;

        .action-item {
          .icon {
            font-size: 55rpx;
          }

          .text {
            display: block;
            font-size: 25rpx;
            margin: 20rpx 0rpx;
          }
        }
      }
    }
  }
</style>
